home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / usr / lib / os-probes / mounted / 20microsoft < prev    next >
Encoding:
Text File  |  2007-03-14  |  1.9 KB  |  63 lines

  1. #!/bin/sh
  2. # Detects all Microsoft OSes on a collection of partitions.
  3.  
  4. . /usr/share/os-prober/common.sh
  5.  
  6. partition=$1
  7. mpoint=$2
  8. type=$3
  9.  
  10. # Weed out stuff that doesn't apply to us
  11. case "$type" in
  12.   ntfs) debug "$1 is a NTFS partition" ;;
  13.   vfat) debug "$1 is a FAT32 partition" ;;
  14.   msdos) debug "$1 is a FAT16 partition" ;;
  15.   *) debug "$1 is not a MS partition: exiting"; exit 1 ;;
  16. esac
  17.  
  18. # Vista/Longhorn
  19. if [ -e "$2/bootmgr" ] && [ -e "$2/Boot/BCD" ]; then
  20.   long="Windows Vista/Longhorn (loader)"
  21.   short=Windows
  22. # 2000/XP/NT4.0
  23. elif ([ -e "$2/ntldr" ] || [ -e "$2/NTLDR" ]) && \
  24.      ([ -e "$2/ntdetect.com" ] || [ -e "$2/NTDETECT.COM" ]); then
  25.   long="Windows NT/2000/XP"
  26.   short=Windows
  27.   if [ -e "$2/boot.ini" ]; then
  28.     multicount="$(grep -e "^multi" $2/boot.ini | wc -l)"
  29.     scsicount="$(grep -e "^scsi" $2/boot.ini | wc -l)"
  30.     msoscount="$(expr ${multicount} + ${scsicount})"
  31.     if [ $msoscount -eq 1 ]; then
  32.       # We need to remove a Carriage Return at the end of the line...
  33.       defaultmspart="$(grep -e "^default=" $2/boot.ini | cut -d '=' -f2 | tr -d '\r')"
  34.       # Escape any backslashes in defaultmspart
  35.       grepexp="^$(echo $defaultmspart | sed -e 's/\\/\\\\/')="
  36.       # Colons not allowed; replace by spaces
  37.       # Accented characters (non UTF-8) cause debconf to hang, so we fall back
  38.       # to the default if the name contains any weird characters.
  39.       long="$(grep -e "$grepexp" $2/boot.ini | cut -d '"' -f2 | \
  40.             tr ':' ' ' | grep -v '[^a-zA-Z0-9 &()/_-]')"
  41.       if [ -z "$long" ]; then
  42.         long="Windows NT/2000/XP"
  43.       fi
  44.     else
  45.       long="Windows NT/2000/XP (loader)"
  46.     fi
  47.   fi
  48. # MS-DOS
  49. elif [ -d "$2/dos" ]; then
  50.   long="MS-DOS 5.x/6.x/Win3.1"
  51.   short=MS-DOS
  52. # 95/98/Me
  53. elif [ -e "$2/windows/win.com" ]; then
  54.   long="Windows 95/98/Me"
  55.   short=Windows9xMe
  56. else
  57.   exit 1
  58. fi
  59.  
  60. label=$(count_next_label $short)
  61. result "${partition}:${long}:${label}:chain"
  62. exit 0
  63.